<!DOCTYPE HTML>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title><? echo $title ?></title>
    <? require("lib.php"); ?>
    <link rel="stylesheet" href="css/jquery.datetimepicker.css" type="text/css" media="screen" />
    <script type="text/javascript" src="js/jquery.datetimepicker.js"></script>
</head>
<body>
<div class="content-box"><!-- Start Content Box -->
    <div class="content-box-header">
        <h3><? echo $title ?></h3>
        <div class="clear"></div>
    </div> <!-- End .content-box-header -->
    <div class="content-box-content">
        <?
        switch ($do) {
            case "add":
                add();
                break;
            case "update":
                update($info);
                break;
            case "delete":
                delete($id);
                break;
            default:
                show_info($info);
        }
        ?>
        <? function show_box($row, $iseditmode, $isadd=0){
            global $id, $h, $url, $title, $sales_promotion, $baseurl, $option, $lang, $code_array;
            $name = isset($row['name_'.$lang]) ? $row['name_'.$lang] : '';
            $is_filter = isset($row['is_filter']) ? $row['is_filter'] : 0;
            $is_index = isset($row['is_index']) ? $row['is_index'] : 0;

            ?>
            <script type="text/javascript">
                $(function(){
                    <?if($is_filter){?>
                        $('input:radio[name="is_filter"]').eq(0).attr('checked', 'true');
                    <?}else{?>
                        $('input:radio[name="is_filter"]').eq(1).attr('checked', 'true');
                    <?}?>
                    <?if($is_index){?>
                    $('input:radio[name="is_index"]').eq(0).attr('checked', 'true');
                    <?}else{?>
                    $('input:radio[name="is_index"]').eq(1).attr('checked', 'true');
                    <?}?>

                });
            </script>
            <table width="99%" cellspacing="0" cellpadding="3" class="mbox">
                <tr class="th"><td class="thtitle" width="120" align="right"><? echo $title ?></td>
                    <td><? if(isset($row['id'])) echo $h->hidden('id', iso($row["id"])); ?></td></tr>
                <tr><td class="l"><?=ROOT_TAGS_NAME?></td><td><? echo $h->text('name', $name, 'g') ?></td></tr>
                <tr><td class="l"><?=ROOT_TAGS_IS_FILTER?></td><td><input type="radio" value="1" name="is_filter" class="g" />&nbsp;<?=ROOT_TAGS_IS_FILTER_YES?>&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" value="0" name="is_filter" class="g" />&nbsp;<?=ROOT_TAGS_IS_FILTER_NO?> </td></tr>
                <tr><td class="l"><?=ROOT_TAGS_IS_INDEX?></td><td><input type="radio" value="1" name="is_index" class="g" />&nbsp;<?=ROOT_TAGS_IS_INDEX_YES?>&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" value="0" name="is_index" class="g"/>&nbsp;<?=ROOT_TAGS_IS_INDEX_NO?> </td></tr>

                <tr><td class="l">&nbsp;</td><td><br><? echo $h->submit('save', '&nbsp; '.ROOT_SAVE.' &nbsp;', $iseditmode==1?'button':'hide') ?>&nbsp;&nbsp;<a onClick="history.go(-1)">[ <?=ROOT_CANCEL?> ]</a><br><br></td></tr>
            </table>
        <? } ?>
        <? function show_boxes($result){
            global $url, $page, $pages, $type, $s, $lang, $arrlang, $filter, $h, $code_array;
            $str='<table width="99%" class="mlist"><tr>';  // 搜索
            $str.='<td><form action="'.$url.'.php" method="get"><input type="hidden" value="'.$type.'" name="type" /><input type="hidden" name="filter" value="'.$filter.'"/><input placeholder="" name="s" class="g" value="'.$s.'" /> &nbsp; <input type="submit" class="button_blue" value=" '.ROOT_SEARCH.' " /></form></td>';
            $str.='<td align="right"></td>';
            $str.='</tr></table>';
            $str.='<table width="99%" cellspacing="0" class="mlist"><tr class="th"><td><strong>'.ROOT_TAGS_NAME.'</strong></td><td><strong>'.ROOT_TAGS_TYPE.'</strong></td><td><strong>'.ROOT_TAGS_IS_FILTER.'</strong></td><td><strong>'.ROOT_TAGS_IS_INDEX.'</strong></td><td><a href="'.$url.'.php?type='.$type.'&do=add">[ '.ROOT_TAGS_ADD.' ]</a></td></tr>';
            $count=1;
            foreach( $result as $row)
            {
                $id=$row['id'];
                $name = $row['name_'.$lang];
                $tem_cate = $code_array['tags_type'][$type]['name_'.$lang];
                $tem_url = 'tag_list.php?tag_id='.$id;
                $tem_type_tip=ROOT_TAGS_PRODUCT;
                if($type==2)$tem_type_tip=ROOT_TAGS_DOCUMENT;
                $is_filter = '-';
                if($row['is_filter'] == 1){
                    $is_filter = ROOT_TAGS_IS_FILTER_YES;
                }
                $is_index = '-';
                if($row['is_index'] == 1){
                    $is_index = ROOT_TAGS_IS_INDEX_YES;
                }

                $str.="<tr><td><a href='".$tem_url."'>".$name."(".$row['count'].")</a></td><td>".$tem_cate."</td><td>".$is_filter."</td><td>".$is_index."</td><td><a href='".$tem_url."'>".$tem_type_tip."</a> | <a href=\"$url.php?do=update&id=".$id."\">".ROOT_UPDATE."</a> | <a href=\"$url.php?do=delete&id=".$id."\" onClick=\"javascript: return delc();\">".ROOT_DELETE."</a></td></tr>";
                $count++;
            }
            $str.= "</table>";
            echo $str;
            if($count==1) echo "<br>No data now. (".ROOT_NO_DATA."!)";
            echo echo_page_raw($page, $pages, $url.'.php?filter='.$filter.'&page=');
        } ?>
        <br class="clear" />
    </div> <!-- End .content-box-content -->
    <br class="clear" />
</div><!-- End .content-box -->
</body>
</html>
